home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_dev-disk / egsdemos / egsexamples / asm / hook.asm < prev    next >
Encoding:
Assembly Source File  |  1994-06-06  |  6.7 KB  |  327 lines

  1. *
  2. *  hook.asm -- Asm example that calls the EL_InstallLIHook function
  3. *
  4. *  $
  5. *  $ FILE     : E_G_S:Wartung&Pflege/A-Include/egs/hook.asm
  6. *  $ VERSION  : 1
  7. *  $ REVISION : 78
  8. *  $ DATE     : 10-Mar-93 12:40
  9. *  $
  10. *  $ Author   : mvk
  11. *  $
  12. *
  13. *
  14. *
  15. *
  16. *
  17. *
  18. *
  19. *
  20.  
  21.    INCLUDE   "exec/types.i"
  22.    INCLUDE   "exec/macros.i"
  23.    INCLUDE   "exec/libraries.i"
  24.    INCLUDE   "exec/nodes.i"
  25.    INCLUDE   "exec/ports.i"
  26.  
  27.    INCLUDE "egs/egs.i"
  28.    INCLUDE "egs/egsblit.i"
  29.    INCLUDE "egs/egslayers.i"
  30.    INCLUDE "egs/egsgfx.i"
  31.    INCLUDE "egs/egsintuigfx.i"
  32.    INCLUDE "egs/egsintui.i"
  33.  
  34.    INCLUDE "egs/lvo/lvo_egs.i"
  35.    INCLUDE "egs/lvo/lvo_egsblit.i"
  36.    INCLUDE "egs/lvo/lvo_egslayers.i"
  37.    INCLUDE "egs/lvo/lvo_egsgfx.i"
  38.    INCLUDE "egs/lvo/lvo_egsintui.i"
  39.  
  40.    XDEF   _main
  41.  
  42.    XREF   _printf
  43.    XREF   _AbsExecBase
  44.  
  45.  
  46.    EXTERN_LIB   OpenLibrary
  47.    EXTERN_LIB   CloseLibrary
  48.    EXTERN_LIB   GetMsg
  49.    EXTERN_LIB   WaitPort
  50.    EXTERN_LIB   ReplyMsg
  51.  
  52.  
  53.  STRUCTURE  my_libs,0
  54.     APTR    my_egsblit
  55.     APTR    my_egsintui
  56.     APTR    my_egslayer
  57.     APTR    my_win
  58.     APTR    my_layer
  59.     APTR    my_msg
  60.     APTR    my_port
  61.     LABEL   my_SIZE
  62.  
  63.     section   code
  64.  
  65.  
  66. _main:
  67.    ;------ open the test library: this will bring it in from disk
  68.    move.l   _AbsExecBase,a6
  69.    lea      -my_SIZE(a7),a7           ;Sturcture Memory
  70.    move.l   a7,a5
  71.    move.l   a7,myptr
  72.  
  73.    lea      egsblitName(pc),a1
  74.    moveq    #0,d0
  75.    CALLLIB  _LVOOpenLibrary
  76.    move.l   d0,my_egsblit(a5)
  77.  
  78.    lea      egslayerName(pc),a1
  79.    moveq    #0,d0
  80.    CALLLIB  _LVOOpenLibrary
  81.    move.l   d0,my_egslayer(a5)
  82.  
  83.    lea      egsintuiName(pc),a1
  84.    moveq    #0,d0
  85.    CALLLIB  _LVOOpenLibrary
  86.    move.l   d0,my_egsintui(a5)
  87.  
  88.    tst.l    d0
  89.    bne.s    1$
  90.  
  91.    ;------ couldn't find the library
  92.  
  93.    pea      LibsName(pc)
  94.    pea      nolibmsg(pc)
  95.    jsr      _printf
  96.    addq.l   #8,sp
  97.  
  98.    bra      main_end
  99.  
  100. 1$:
  101.  
  102.    pea      LibsName(pc)
  103.    pea      Msg1(pc)
  104.    jsr      _printf
  105.    addq.l   #8,sp          ;fix 2 long stack pushes
  106.  
  107.    ;------ print the library name, version, and revision
  108.    clr.l    d0
  109.  
  110.    pea      Msg2(pc)
  111.    jsr      _printf
  112.    addq.l   #4,sp
  113.  
  114.    ;------ call the first test function
  115.  
  116.    lea       mywin,a0
  117.    LINKLIB   _LVOEI_OpenWindow,my_egsintui(a5)
  118.  
  119.    tst.l    d0
  120.    bne      2$
  121.  
  122.    pea      Msg4(pc)
  123.    jsr      _printf
  124.    addq.l   #4,sp          ;fix 1 long stack pushes
  125.  
  126.    bra      3$
  127.  
  128. 2$:
  129.  
  130.    move.l     d0,my_win(a5)
  131.    move.l     d0,a0
  132.    move.l     eiwi_UserPort(a0),my_port(a5)
  133.  
  134.    move.l     eiwi_WLayer(a0),a0
  135.    move.l     ella_LayerInfo(a0),my_layer(a5)
  136.  
  137.    move.l     my_layer(a5),a0
  138.    lea        hook,a1
  139.    LINKLIB   _LVOEL_InstallLIHook,my_egslayer(a5)
  140.  
  141. ;
  142. ;  Message Handeling
  143. ;
  144.  
  145. 5$:
  146.         move.l    my_port(a5),a0
  147.         CALLLIB   _LVOWaitPort
  148.         move.l    my_port(a5),a0
  149.         CALLLIB   _LVOGetMsg
  150.         move.l    d0,my_msg(a5)
  151.         move.l    d0,a1
  152.         CALLLIB   _LVOReplyMsg
  153.  
  154.         move.l    my_msg(a5),a1
  155.         move.l    eims_Class(a1),d0
  156.         cmp.l     #EI_iCLOSEWINDOW,d0
  157.  
  158.         bne.b   5$
  159.  
  160. ;
  161. ;  Close
  162. ;
  163.  
  164.  
  165.    pea        Msg5(pc)
  166.    jsr       _printf
  167.    addq.l     #4,sp          ;fix 1 long stack pushes
  168.  
  169.    move.l     my_win(a5),a0
  170.    LINKLIB   _LVOEI_CloseWindow,my_egsintui(a5)
  171.  
  172.    move.l     my_layer(a5),a0                        ;Remove Hook
  173.    move.l     #0,a1
  174.    LINKLIB   _LVOEL_InstallLIHook,my_egslayer(a5)
  175.  
  176. 3$:
  177.    ;------ close the egs.library
  178.  
  179.    move.l   _AbsExecBase,a6
  180.    move.l   my_egsblit(a5),a1
  181.    CALLLIB  _LVOCloseLibrary
  182.  
  183.    move.l   my_egslayer(a5),a1
  184.    CALLLIB  _LVOCloseLibrary
  185.  
  186.    ;------ close the egsblit.library
  187.    move.l   my_egsintui(a5),a1
  188.    CALLLIB  _LVOCloseLibrary
  189.  
  190. main_end:
  191.         lea                 my_SIZE(a7),a7
  192.         moveq               #0,d0
  193.         rts
  194.  
  195.  STRUCTURE  my_apply,0
  196.     LONG    map
  197.     LONG    data
  198.     LONG    x
  199.     LONG    y
  200.     LONG    w
  201.     LONG    h
  202.     LONG    ox
  203.     LONG    oy
  204.     LONG    c
  205.     LABEL   my_MEM
  206.  
  207. ;
  208. ;           Hookroutine for screen
  209. ;
  210. ;           it makes a colorflow in the background of the screen
  211. ;
  212.  
  213. myapply:
  214.         ; in A0 = EBitMap
  215.         ; in A1 = Data
  216.         ; d0 = x
  217.         ; d1 = y
  218.         ; d2 = width
  219.         ; d3 = height
  220.         ; d4 = ox
  221.         ; d5 = oy
  222.  
  223.         movem.l              d2-d7/a2-a7,-(sp)
  224.         lea                  -my_MEM(a7),a7        ; get memory
  225.         move.l                     myptr,a5        ; get pointer for
  226.                                ; calling EGS-Library
  227.  
  228.         move.l               a0,map(a7)            ; save parameter
  229.         move.w               d0,x(a7)
  230.         move.w               d1,y(a7)
  231.         move.w               d2,w(a7)
  232.         move.w               d3,h(a7)
  233.         move.w               d4,ox(a7)
  234.         move.w               d5,oy(a7)
  235.  
  236.         moveq                #0,d6
  237.         moveq                #0,d7
  238.         move.w               d1,d6                 ; loop counter
  239.         add.w                d1,d3
  240.         sub.w                #1,d3                 ; y + h - 1
  241.         move.w               d3,d7                 ; end of loop
  242. 4$:
  243. ;
  244. ;           compute the colorflow
  245. ;
  246.  
  247.         moveq                     #0,d0
  248.         move.l                    d6,d0
  249.         asl.l                     #8,d0
  250.  
  251. ;
  252. ;           put the parameter in register for RectangleFill
  253. ;
  254.         move.l               map(a7),a0
  255.         move.w                 x(a7),d1
  256.         move.l                    d6,d2            ; loop counter
  257.         move.w                 w(a7),d3
  258.         moveq                     #1,d4            ; 1 pixel high
  259.         moveq                     #0,d5
  260.  
  261.         LINKLIB              _LVOEB_RectangleFill,my_egsblit(a5)
  262.  
  263.         addq                 #1,d6
  264.  
  265.         cmp.w                d7,d6
  266.         ble.b                4$                    ; loop
  267.                                ; because the high is 1
  268.                                ; pixel
  269.  
  270.         lea                  my_MEM(a7),a7         ; give memory back
  271.         movem.l              (sp)+,d2-d7/a2-a7
  272.         rts
  273.  
  274. ScreenMode1:   dc.b   'NEXT 1120x832',0
  275. ScreenMode:    dc.l     0
  276. myptr:         dc.l    0
  277. hoehe:         dc.l    0
  278.  
  279. mywin:       dc.w    100
  280.          dc.w    100
  281.          dc.w    100
  282.          dc.w    1
  283.          dc.w    0
  284.          dc.w    0
  285.          dc.w    0
  286.          dc.w    0
  287.          dc.l    0
  288.          dc.l    EI_WINDOWCLOSE!EI_WINDOWBACK!EI_WINDOWDRAG
  289.          dc.l    0
  290.          dc.l    name
  291.          dc.l    0
  292.          dc.l    EI_iCLOSEWINDOW
  293.          dc.l    0
  294. color:
  295.          dc.l    0  ;1
  296.          dc.l    0  ;2
  297.          dc.l    0  ;3
  298.          dc.l    0  ;4
  299.          dc.l    0  ;5
  300.          dc.l    0  ;6
  301.          dc.l    0  ;8
  302.          dc.l    0  ;Menu
  303.          dc.l    0  ; Render
  304.          dc.l    0  ; Render
  305. hook:
  306.          dc.l    myapply
  307.          dc.l    0
  308.  
  309. name:         dc.b   'hook',0
  310. egsName:      dc.b   'egs.library',0
  311. egsblitName:  dc.b   'egsblit.library',0
  312. LibsName:     dc.b   'EGS libs',0
  313. egslayerName: dc.b   'egslayers.library',0
  314. egsintuiName: dc.b   'egsintui.library',0
  315. nolibmsg:     dc.b   'Can not open library "%s"',10,0
  316. Msg1:         dc.b   'Open library "%s"',10,0
  317. Msg2:         dc.b   'Call EI_OpenWindw',10,0
  318. Msg4:         dc.b   'Cant Open Window',10,0
  319. Msg5:         dc.b   'Call EI_CloseWindow',10,0
  320.  
  321.         cnop 4,0
  322.  
  323.            END
  324.  
  325.  
  326. <
  327.